package com.qiaofang.applet.service.property.service;

import com.qiaofang.applet.common.base.BaseService;
import com.qiaofang.applet.service.member.domain.MemberSubscribe;
import com.qiaofang.applet.service.other.domain.FirsthandRules;
import com.qiaofang.applet.service.property.domain.FirsthandEstate;
import com.qiaofang.applet.service.property.service.dto.*;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.mongodb.core.query.Query;

import java.util.List;

/**
 * 新房服务接口
 *
 * @author daiyuxiang
 * @Time 2020-09-30
 */
public interface FirsthandEstateService extends BaseService<FirsthandEstate, String> {
    FirsthandEstate findByEstateUuidAndCityCode(String estateUuid, String cityCode);


    /**
     * 根据新房唯一UUID查询新房对象
     *
     * @param estateUniqueUuid: 新房唯一UUID
     * @return PaFirsthandEstate: 新房
     * @author daiyuxiang
     */
    FirsthandEstate findByEstateUniqueUuid(String estateUniqueUuid);

    /**
     * 分页查询新房
     *
     * @param queryDto: 查询条件
     * @param pageable: 分页条件
     * @return Page<FirsthandEstate>: 分页新房集合
     * @author daiyuxiang
     */
    Page<FirsthandEstate> findAllByParams(FirsthandEstateQueryDto queryDto, Pageable pageable);

    /**
     * 首页主推房源需要排序
     * @param queryDto
     * @param pageable
     * @return
     */
    Page<FirsthandEstate> findAllHotFirsthandByParams(FirsthandEstateQueryDto queryDto, Pageable pageable);

    /**
     * 查询新房
     *
     * @param queryDto: 查询条件
     * @return List<FirsthandEstate>: 新房集合
     * @author daiyuxiang
     */
    List<FirsthandEstate> findAllByParams(FirsthandEstateQueryDto queryDto);

    Page<FirsthandEstate> findAllByUuids(FirsthandEstateQueryDto queryDto, Pageable pageable);

    /**
     * 查询新房 随机排序
     *
     * @param queryDto: 查询条件
     * @return List<FirsthandEstate>: 新房集合
     * @author daiyuxiang
     */
    List<FirsthandEstate> findAllByParamsAndRand(FirsthandEstateQueryDto queryDto);

    /**
     * 猜你喜欢 新房楼盘pk用
     * @param queryDto
     * @param pageable
     * @return
     */
    List<FirsthandEstate> findAllByParamsAndRandForEstatePK(FirstEstateGuessLikeForPKDto queryDto, Pageable pageable);
    /**
     * 更新新房信息
     *
     * @param firsthandEstate
     */
    void updateFirsthandEstate(FirsthandEstate firsthandEstate);

    /**
     * 批量下架新房楼盘
     * @param firsthandRules
     * @param corporationCode
     * @param currentTimeMillis
     * @return
     */
    long batchDownFirsthand(FirsthandRules firsthandRules, String corporationCode, long currentTimeMillis);

    /**
     * 获取未被上下架规则处理的新房uuid集合
     * @param companyUuid
     * @param currentTimeMillis
     * @return
     */
    List<String> getUndisposedUuidList(String companyUuid, long currentTimeMillis);

    /**
     * 通过uuid集合批量处理新房上下架
     * @param uuidList
     * @param companyUuid
     * @param upDownFlag
     * @return
     */
    long batchProcessingByUuidList(List<String> uuidList, String companyUuid, String upDownFlag);

    Page<FirstEstateSubscribeDto> domainToPageDto(Page<FirsthandEstate> firsthandEstatePage, List<MemberSubscribe> subscribeList);

    /**
     * 对比新房数据
     * @param comparedEstateDto
     * @return
     */
    List<FirsthandEstateComparedDetailDto> comparedEstateData(ComparedEstateDto comparedEstateDto);

    /**
     * 新房固定展示位经纪人手机号
     * @param uniqueUuid
     * @return
     */
    String getFirstEstateEmployeePhone(String uniqueUuid);

    /**
     * 处理新房户型图水印
     * @param list
     * @return
     */
    List<EstateHouseTypeDetailDto> dealEstateHouseTypeWaterMark(List<EstateHouseTypeDetailDto> list);
}
